<template>
  <dt-modal-edit
    ref="modal"
    title="申请延期发起"
    :label-width="130"
    :width="500"
    @ok="onOk"
    :loading="loading"></dt-modal-edit>
</template>

<script>
  import Opt from '../opt/deferOpt.js'
  import extendMgr from '@/biz/bonus/bonusExtend.js'

  export default {
    data() {
      return {
        info: {
          housesId: '',
          housesName: '',
          extendReason: 'BUSINESS',
          applyMonth: '',
          oaNumber: null,
          remark: null
        },
        loading: false
      }
    },
    methods: {
      show() {
        this.info.housesId = this.$dt.buildInfo().housesId
        this.info.housesName = this.$dt.buildInfo().housesName
        extendMgr.getBoApplyMonth().then((resMonth) => {
          this.info.applyMonth = resMonth
          this.$refs.modal.show(new Opt(this.info))
        })
      },
      hide() {
        this.$refs.modal.hide()
      },
      onOk() {
        extendMgr
          .createExtend(this.info)
          .then((res) => {
            this.$router.push({
              path: `deferLog`,
              query: {}
            })
            this.loading = false
          })
          .catch((err) => {
            this.loading = false
          })
      }
    }
  }
</script>

<style></style>
